// router目录负责路由相关内容，如定义路由及路由处理函数，路由加载的中间件等
package router

import (
	"hello-gin/middleware"

	"github.com/gin-gonic/gin"
)

// Load中负责加载中间件middlewares、路由routes和handlers
func Load(g *gin.Engine, mw ...gin.HandlerFunc) *gin.Engine {
	// 添加路由 /
	g.GET("/", func(c *gin.Context) {
		c.String(200, "Hello, Go Gin Web!")
	})

	// 添加路由 /version
	g.GET("/version", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"version": "20230415!",
			"app":     "RESTful-Api",
		})
		middleware.Logger.Error("错误日志")
		middleware.Logger.Info("常规日志")
		middleware.Logger.Debug("BUG日志")

	})

	// 加载中间件
	g.Use(mw...)
	return g
}
